package com.itheima.Demo1Scanner;

import java.util.Scanner;

public class Demo05 {
    public static void main(String[] args) {
        String username = "admin";
        String password = "12546";

        //
        Scanner sc = new Scanner(System.in);
        for(int i = 1; i <= 3;i++){
            System.out.println("请输入用户名:");
            String scUsername = sc.next();
            System.out.println("请输入密码:");
            String scPassword = sc.next();

            if(username.equals(scUsername) && password.equals(scPassword)){
                System.out.println("登录成功");
                break;
            }else {
                if(i == 3){
                    System.out.println("您的登录次数以达到今日上限,请明日再来");
                }
                System.out.println("登录失败,您还剩余"+(3-i)+"次机会");
            }
        }
    }
}
